package com.dfrz.household.controller;/*
 * @创建者：黄苟苟
 * @创建时间：2021/8/10   16:46
 * @Description描述
 **/

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dfrz.household.bean.Server;
import com.dfrz.household.bean.ServerPerson;
import com.dfrz.household.bean.User;
import com.dfrz.household.service.ServerPersonService;
import com.dfrz.household.utils.Result;
import com.dfrz.household.utils.ResultUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;

@RestController
public class ServerPersonController {
    Logger logger=LoggerFactory.getLogger(ServerPersonController.class);
    @Autowired
    ServerPersonService serverPersonService;
    @RequestMapping("/listSerPerson")
    public Result listSerPerson(String sername,Integer pageNo,Integer pageSize){
        Map <String,String> parm=new HashMap <>();
        parm.put("sername",sername);
        IPage<ServerPerson>  pageser=serverPersonService.getUserByPage(parm,pageNo,pageSize);
        Integer total=(int)pageser.getTotal();
        Result result= ResultUtils.success(pageser.getRecords());
//        总记录数
        result.setCount(total);
        return result;
    }
    @RequestMapping("/toSerlist")
    public ModelAndView toSerlist(){
        List<ServerPerson> list=serverPersonService.getAllSerperson();
        ModelAndView mv=new ModelAndView();
        mv.addObject("mv",list);
        mv.setViewName("master");
        return mv;
    }
    //转向shifuid页面
    @RequestMapping("/toshifuid")
    public ModelAndView toshifuid(Integer serid) {
        ModelAndView mv = new ModelAndView("/shifuid");
          ServerPerson  serverPerson=serverPersonService.getServerpersonCompanyById(serid);
          mv.addObject("serverperson",serverPerson);
        return mv;
    }

}
